package com.itdaan.portal.business.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.itdaan.portal.business.domain.Role;
import com.itdaan.portal.business.mapper.RoleMapper;
import com.itdaan.portal.business.service.RoleService;
import com.itdaan.portal.common.exception.ServiceException;
/**
 * @author www.itdaan.com
 */
@Service(value = "roleService")
public class RoleServiceImpl implements RoleService{
	
	@Autowired
	private RoleMapper roleMapper;
	
	public void insert(Role role) throws ServiceException {
		roleMapper.insert(role);
	}

	public void deleteById(int id) throws ServiceException  {
		roleMapper.deleteById(id);
	}

	public void deleteByIds(String ids) throws ServiceException  {
		for (String id : ids.split(",")) {
			roleMapper.deleteById(Integer.parseInt(id));
		}
	}
	
	public void update(Role role) throws ServiceException  {
		roleMapper.update(role);
	}
	
	public Role getById(int id) throws ServiceException  {
		return roleMapper.getById(id);
	}

	public List<Role> getAll() throws ServiceException  {
		return roleMapper.getAll();
	}
	
	public List<Role> getByUserId(int userId) throws ServiceException {
		return roleMapper.getByUserId(userId);
	}
	
}
